﻿Imports System.Data
Imports System.Data.SqlClient

Public Class Form1
    Dim SQLConn As New SqlConnection(Configuration.ConfigurationManager.ConnectionStrings("mosq.My.MySettings.mosqConnectionString").ToString)
    Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
        'TODO: This line of code loads data into the 'MosqDataSet.city' table. You can move, or remove it, as needed.
        Try

            Dim SQLStr As String = "select * from emp"


            'Dim cmd As New SqlCommand(SQLStr, SQLConn)

            'Dim rs As SqlDataReader
            SQLConn.Open()

            Dim ds As New DataSet()

            Dim ad As New SqlDataAdapter(SQLStr, SQLConn)


            ad.Fill(ds, "Emps")


            DataGridView1.DataSource = ds.Tables(0)

            'DataGridView1.Refresh()



            SQLConn.Close()




        Catch ex As Exception
            MsgBox(ex.Message)
        End Try




    End Sub


    Private Sub BtnSer_Click(sender As System.Object, e As System.EventArgs) Handles BtnSer.Click


        Try

            Dim SQLStr As String = "select * from emp where E_cardnum='" & TxtSer.Text & "'"


            'Dim cmd As New SqlCommand(SQLStr, SQLConn)

            'Dim rs As SqlDataReader
            SQLConn.Open()

            Dim ds As New DataSet()

            Dim ad As New SqlDataAdapter(SQLStr, SQLConn)


            ad.Fill(ds, "Emps")


            DataGridView1.DataSource = ds.Tables(0)

            'DataGridView1.Refresh()



            SQLConn.Close()




        Catch ex As Exception
            MsgBox(ex.Message)
        End Try



    End Sub
End Class
